<?php
include dirname(dirname(__FILE__)).'/admin-verify.php';
include dirname(__FILE__).'/functions.php';
?>

<!DOCTYPE html>
<html>
<head>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php' ?>
		<script type="text/javascript">
		$(document).ready(function (){
			jQuery(".del").click(function() {
				var id = jQuery(this).val();
				$.ajax({
				dataType:"text",
				url:'ajax/delete.php',
				data:{id:id},
				success:function(data) {
					if(data=='yes') {
					alert("删除成功！");
					window.location="";

					} else {
						alert("删除失败！");
						window.location="";

					}
				},
			});
				
			});
		
		});
		</script>
		<link rel="stylesheet" type="text/css" href="../css/style.css">
		<title>公告管理</title>
</head>
<body class="container">

	<div class="col-md-12">
		<div>
			<h3>公告管理</h3>
		</div>
		<div>
			  	<table class="table table-striped table-bordered table-hover table-condensed" id="default-table">
				  <tr>
				  	<th>标题</th>
				  	<th>修改时间</th>
				  	<th>发布用户</th>
				  	<th>操作</th>
				  </tr>
				  <?php
				  	$ret=getAllAnnouncement();
				 	while($item=mysql_fetch_array($ret)){
				 	 	echo "<tr>";
				  		echo "<td>".$item['title']."</td>";
				  		echo "<td>".$item['date']."</td>";
				  		echo "<td>".$item['username']."</td>";
				  		echo "<td>
				  		<a href='edit.php?id=".$item['id']."'"."class='btn btn-primary'>查看</a>
				  		<button value='".$item['id']."'"."class='btn btn-primary del'>删除</button></td>";
				  		echo "</tr>";
				   } 
				  ?>
				</table>
			  </div>
	</div>
		<div class="row">
		<div class="col-md-9"></div>
		<div class="col-md-3"><a href="edit.php" class="btn btn-primary">新增</a> </div>
	</div>
	
</body>
</html>